from selenium.webdriver.common.by import By
from pom.base_page import BasePage
import time


class EngineManagePage(BasePage):
    def base_info(self):
        self.driver.find_element(By.XPATH, '//div[2]/div/div[1]/div[2]/div[1]/div/ul/div[13]/li/ul/div[1]/a/li').click()

        time.sleep(2)
        category = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[3]/div').text
        version = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[6]/div').text
        os = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[8]/div').text
        print(category, version, os, "***************")

        assert category == "mysql"
        assert version == "3.7.0"
        assert os == "Windows"

    def engine_install(self):
        self.driver.find_element(By.XPATH, '//div[2]/div/div[1]/div[2]/div[1]/div/ul/div[13]/li/ul/div[2]/a/li').click()

        time.sleep(2)
        code = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[3]/div').text
        status = self.driver.find_element(By.XPATH,
                                          '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[10]/div/span').text
        print(code, status)

        assert code == "1"
        assert status == "正常"

    def engine_log(self):
        self.driver.find_element(By.XPATH, '//div[2]/div/div[1]/div[2]/div[1]/div/ul/div[13]/li/ul/div[3]/a/li').click()

        time.sleep(2)
        event = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[3]/div/span').text
        engine_app = self.driver.find_element(By.XPATH, '//div[2]/div/div[2]//div/div[2]/div[3]//tr[1]/td[8]/div').text
        print(event, engine_app, "***************")

        assert event == "其他"
        assert engine_app == "dbTest"
